<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport"
	content="width=device-width, minimum-scale=1, initial-scale=1, maximum-scale=1, user-scalable=no"
	charset="UTF-8">
<link rel="stylesheet" href="android_asset://css/style.css" />
<link rel="stylesheet" href="android_asset://css/font.css" />
<title>附件信息</title>
<style type="text/css">
   
</style>
</head>
<body>
	<form id="form">
		<div class="accessory_info">
			<div class="item">
				<div class="listing">
					<div class="clearfix borderbot">
						<ul id="work-ul" class="work-ul work-ul_text" style="padding:0;margin:0">
							<li style="width:15%"><span class='icon-add'
								onclick="uploadMenu('.work-ul',1)"></span></li>	
						</ul>
					</div>
				</div>
			</div>
			<div class="confirm">
				<button type="button">
					<a href="javascript:void(0);">提交附件</a>
				</button>
			</div>
		</div>
	</form>
</body>
<script src="android_asset://jquery-1.11.0.min.js"
	type="text/javascript"></script>
<script src="android_asset://jquery-migrate-1.2.1.min.js"
	type="text/javascript"></script>
<script src="android_asset://jquery.touchSwipe.min.js"
	type="text/javascript"></script>
<script src="android_asset://bridge.js" type="text/javascript"></script>
<script src="android_asset://android.js" type="text/javascript"></script>
<script>
	//弹出提示框，选择拍照和添加文件
	function uploadMenu(picker, attType) {
		if (msAndroid[picker] == null || msAndroid[picker] < 0) {
			msAndroid[picker] = 0
		}
		var menu = [ {
			text : "添加图片",
			index : 0
		}, {
			text : "添加文件",
			index : 1
		} ];
		msAndroid.menu(menu, function(response) {
			var obj = eval('(' + response + ')');
			if (obj.status == 1) {
				if (obj.data.index == 0) {
					msAndroid.picture(picker, attType, null, true);
				} else if (obj.data.index == 1) {
					msAndroid.file(picker, attType, null);
				}
			} else {
				toast(obj.message);
			}
		}, msAndroid[picker]);
		toCache();
	}
	
	function toCache() {
		//将页面的数据进行缓存
		var formJson = msAndroid.changedTicketVO("#form");
		var attJson = msAndroid.attVO("#form");
		var arg = JSON.stringify(attJson);
		var jsonData = arg;
	}
	
	$(".confirm button").click(			
			function() {
				toCache();
				var work_ul = $("#work-ul img").length;
				if (work_ul == 0) {
					msAndroid.toast("请您至少添加一个附件。");
					return;
				}
				var url = $("#form").attr("action");
				var attJson = msAndroid.attVO("#form");

				if (attJson.original != null) {
					msAndroid.upload("/tickets/{{ticketId}}/attachments/info",attJson,"post",-1,"附件已上传。");
				}
			});
</script>
</html>